<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="top">
        <Top />
      </div>
      <div class="bottom">
        <div class="left">
          <Youk class="Youk" />
          <Sex class="Sex" />

          <Age class="Age" />
        </div>
        <div class="center">
          <Map class="map"></Map>
          <Line class="line"></Line>
        </div>
        <div class="rigth">
          <rank class="rank"></rank>
          <year class="year"></year>
          <counter class="counter"></counter>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
//引入组件
import Top from "./Components/top/index.vue";
import Sex from "./Components/Sex/index.vue";
import Youk from "./Components/YouK/index.vue";
import Age from "./Components/Age/index.vue";
import Map from "./Components/Map/index.vue";
import Line from "./Components/Line/index.vue";
import rank from "./Components/Rank/index.vue";
import year from "./Components/Year/index.vue";
import counter from "./Components/Counter/index.vue";
//获取screen盒子
let screen = ref();
//挂载时调用这个函数
onMounted(() => {
  //设置screen盒子的scale
  screen.value.style.transform = `scale(${getSale()}) translate(-50%,-50%)`;
});
//定义一个函数，用于控制scale的缩放
function getSale(w = 1980, h = 1080) {
  let ww = window.innerWidth / w;
  let wh = window.innerHeight / h;
  return ww > wh ? wh : ww;
}
//监听视口的变化
window.onresize = () => {
  //设置screen盒子的scale
  screen.value.style.transform = `scale(${getSale()}) translate(-50%,-50%)`;
};
</script>

<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background-image: url(./images/bg.png);
  background-repeat: no-repeat;
  background-size: cover;
  .screen {
    position: fixed;
    left: 50%;
    top: 50%;
    width: 1920px;
    height: 1080px;

    transform-origin: left top;
    .top {
      width: 100%;
      height: 40px;
    }
    .bottom {
      display: flex;
      .left {
        flex: 1;
        height: 1040px;
        display: flex;
        flex-direction: column;

        .Sex {
          flex: 1;
        }
        .Youk {
          flex: 1.5;
        }
        .Age {
          flex: 1;
        }
      }
      .rigth {
        flex: 1;
        display: flex;
        flex-direction: column;
        .rank {
          flex: 1;
        }
        .year {
          flex: 1;
        }
        .counter {
          flex: 1;
        }
      }
      .center {
        flex: 2;
        display: flex;
        flex-direction: column;
        .map {
          flex: 3.6;
        }
        .line {
          flex: 1.4;
        }
      }
    }
  }
}
</style>
